#region Summary

// 
// Owner : JackieHan 
// 
// Solution : Skomart.Spider 
// 
// Project : Jackie.Utility.Test
// 
// File : TestConfig.cs
// 
// CopyRight : Copyright © 2010-2011 Skomart Corporation, All Rights Reserved 
// 
// Summary : 测试配置
// 
// History : 
//			2010-10-12 09:52:58	    Create 
// 

#endregion

#region Using

using System;
using System.Collections.Generic;
using System.Xml;
using Jackie.Utility.BvConversion;
using NUnit.Framework;

#endregion

namespace Jackie.Utility.Test.TestConversion.TestConfig
{
    /// <summary> 
    /// 测试配置
    /// </summary>
    [TestFixture]
    public class TestConfig
    {
        [Test]
        public void TestPropertyConfig()
        {
            string configStr = "<property businessProperty='Code' viewProperty='Code' isKey='true' />";

            XmlDocument doc = new XmlDocument();
            doc.LoadXml(configStr);

            XmlNode propertyNode = doc.GetElementsByTagName("property")[0];

            PropertyConfig config = new PropertyConfig(propertyNode);

            Assert.AreEqual(config.BusinessProperty, "Code");
            Assert.AreEqual(config.ViewProperty, "Code");
            Assert.AreEqual(config.IsSubKey, true);
        }

        [Test]
        public void TestConversionConfig()
        {
            string configStr =
                @"<Conversion businessType='A' viewType='AV'>
                        <property businessProperty='PA' viewProperty='PVA' />
                        <property businessProperty='PB.A' viewProperty='PVBA' isKey='true' />
                    </Conversion>";
            XmlDocument doc = new XmlDocument();
            doc.LoadXml(configStr);

            XmlNode configNode = doc.GetElementsByTagName("Conversion")[0];

            ObjectConversionConfig config = new ObjectConversionConfig(configNode);

            Assert.AreEqual(config.BusinessType, "A");
            Assert.AreEqual(config.ViewType, "AV");
            Assert.AreEqual(config.PropertyConfigs.Count, 2);

        }

        [Test]
        public void TestConversionConfigManager()
        {
            ConversionConfigurationManager manager = ConversionConfigurationManager.Instance;

            Assert.AreEqual(manager.BusinessObjectConfig.Count, 1);
        }
    }
}